{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "root = \"pretrained\"\n",
    "models = os.listdir(root)\n",
    "\n",
    "for model in models:\n",
    "    opt = yaml.load(open(f\"{root}/{model}/opt.yaml\", \"r\"), Loader=yaml.FullLoader)\n",
    "    \n",
    "    # remove the keys under data\n",
    "    data = opt[\"data\"]\n",
    "    data.pop(\"nc\", None)\n",
    "    data.pop(\"voxel_size\", None)\n",
    "    data.pop(\"upsample_frac\", None)\n",
    "    data.pop(\"normalize\", None)\n",
    "    opt[\"data\"] = data\n",
    "    \n",
    "    # save the modified opt.yaml\n",
    "    with open(f\"{root}/{model}/opt.yaml\", \"w\") as f:\n",
    "        yaml.dump(opt, f)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "p2pb",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
